{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "certain-pathology",
   "metadata": {},
   "source": [
    "# Series\n",
    "Series由一维数组及索引组成。\n",
    "先导入pandas。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "exciting-insight",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "norwegian-vision",
   "metadata": {},
   "source": [
    "## 最简单的Series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "rental-supply",
   "metadata": {},
   "outputs": [],
   "source": [
    "##keep\n",
    "obj = pd.Series([18753.73, 21462.69, 22990.35])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "convenient-melissa",
   "metadata": {},
   "source": [
    "## 查看值和索引\n",
    "查看obj的索引。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "mobile-occasions",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "a91a82d6",
   "metadata": {},
   "source": [
    "查看obj的值。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aging-technique",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "generous-strength",
   "metadata": {},
   "source": [
    "## 创建时指定索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "interesting-afghanistan",
   "metadata": {},
   "outputs": [],
   "source": [
    "##keep\n",
    "obj2 = pd.Series([18753.73, 21462.69, 22990.35], index=['2007', '2008', '2009'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9420fa29",
   "metadata": {},
   "source": [
    "## 查看obj2值和索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "communist-forty",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "revised-makeup",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "clinical-inclusion",
   "metadata": {},
   "source": [
    "## 访问索引为2007的值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "processed-charlotte",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "99b32003",
   "metadata": {},
   "source": [
    "## 选出2007和2008年的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "pharmaceutical-halifax",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "interested-flash",
   "metadata": {},
   "source": [
    "## 选出大于20000的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "technical-degree",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "modern-disclaimer",
   "metadata": {},
   "source": [
    "## 从Python字典创建Series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "empty-dutch",
   "metadata": {},
   "outputs": [],
   "source": [
    "##keep\n",
    "sdata = {'ShangHai': 2426, 'BeiJing': 2152, 'GuangZhou': 1324, 'ShuZhou': 1060}\n",
    "obj3 = pd.Series(sdata)\n",
    "obj3"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "mathematical-coral",
   "metadata": {},
   "source": [
    "## 使用自定义索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "demonstrated-newport",
   "metadata": {},
   "outputs": [],
   "source": [
    "##keep\n",
    "cities = ['BeiJing', 'GuangZhou', 'ChengDu', 'ShangHai']\n",
    "obj4 = pd.Series(sdata, index = cities)\n",
    "obj4"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "anonymous-guess",
   "metadata": {},
   "source": [
    "## 判断NA值\n",
    "使用pd.isnull函数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "formal-testament",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "07c8c105",
   "metadata": {},
   "source": [
    "使用Series对象自带的isnull方法。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dress-arrest",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "2b0c4d5a",
   "metadata": {},
   "source": [
    "使用notnull方法。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "another-relaxation",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "viral-azerbaijan",
   "metadata": {},
   "source": [
    "## 索引自动对齐\n",
    "查看obj3。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9849fcc1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "4f5337f6",
   "metadata": {},
   "source": [
    "查看obj4。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "severe-millennium",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "0af34258",
   "metadata": {},
   "source": [
    "将obj3和obj4相加。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "agreed-group",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
